//
//  NSError+DetialMessage.m
//  即时通讯
//
//  Created by huangtao on 16/7/11.
//  Copyright © 2016年 fish. All rights reserved.
//

#import "NSError+DetialMessage.h"
#import <AVIMCommon.h>

@implementation NSError (DetialMessage)

- (NSString *)detialMessage
{
    [AVAnalytics event:@"Alert Error" attributes:@{@"desc": self.description}];
    NSString *resultMsg = nil;
        if (self.code == kAVIMErrorConnectionLost) {
            resultMsg = @"未能连接聊天服务";
        }else if (self.code == kAVIMErrorInvalidCommand) {
            resultMsg = @"非法的请求命令";
        }else if (self.code == kAVIMErrorInvalidArguments) {
            resultMsg = @"非法的参数";
        }else if (self.code == kAVIMErrorConversationNotFound) {
            resultMsg = @"会话未找到";
        }else if (self.code == kAVIMErrorTimeout) {
            resultMsg = @"请求超时";
        }else if (self.code == kAVIMErrorConnectionLost) {
            resultMsg = @"连接断开";
        }else if (self.code == kAVIMErrorInvalidData) {
            resultMsg = @"非法数据";
        }else if (self.code == kAVIMErrorMessageTooLong) {
            resultMsg = @"消息内容太长";
        }else if (self.code == kAVIMErrorClientNotOpen) {
            resultMsg = @"client 没有打开";
        }else if ([self.domain isEqualToString:NSURLErrorDomain]) {
             resultMsg = @"网络连接发生错误";
        }else {

            NSString *info = self.localizedDescription;
            resultMsg = info?info:self.description;
        }
    return  resultMsg;
}
@end
